﻿namespace MyTRCP.Common.Models
{
    public class StatusPayload
    {
        public StatusTypeEnum Type { get; set; }
        public byte[] Data { get; set; }
        public StatusPayload(byte[] data)
        {
            Type = (StatusTypeEnum)Tools.Int16FromBEBA(data);
            Data = new byte[data.Length - 2];
            Array.Copy(data, 2, Data, 0, data.Length - 2);
        }
        public byte[] UnparseMe()
        {
            return Unparse(this);
        }
        public static byte[] Unparse(StatusPayload sp)
        {
            byte[] data = new byte[sp.Data.Length + 2];
            Tools.Int16ToBEBA((short)sp.Type, data, 0);
            Array.Copy(sp.Data, 0, data, 2, sp.Data.Length);
            return data;
        }
    }
}